﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kovan.Model.Entity.Config;

namespace Kovan.DAL.Config
{
    public class DNewsData : IDAL<tb_newsData>
    {
        public tb_newsData GetModel(long id)
        {
            using (var db = new MysqlContext())
            {
                return db.tb_newsData.FirstOrDefault(c => c.id == id);
            }
        }

        public int Add(tb_newsData model)
        {
            using (var db = new MysqlContext())
            {
                db.tb_newsData.Add(model);
                return db.SaveChanges();
            }
        }

        public int Delete(long id)
        {
            throw new NotImplementedException();
        }

        public int Update(tb_newsData model)
        {
            using (var db = new MysqlContext())
            {
                db.Set<tb_newsData>().Attach(model);
                db.Entry(model).State = System.Data.EntityState.Modified;
                return db.SaveChanges();
            }
        }

        public int BatchDelete(IEnumerable<string> ids)
        {
            throw new NotImplementedException();
        }
    }
}
